class Solution
{
public:
    ListNode* getIntersectionNode(ListNode* headA, ListNode* headB)
    {
        ListNode* n1 = headA;
        ListNode* n2 = headB;

        while (n1 != n2)
        {
            n1 = n1 != NULL ? n1->next : headB;
            n2 = n2 != NULL ? n2->next : headA;
        }
        return n1;
    }
};